﻿using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;

namespace RobotEscape.Entities
{
    public class EntityBase
    {
        #region props
        public int Id;
        public UIElement uiElement;
        private Point _position = new Point(0, 0);
        private Point _tilePosition = new Point(0, 0);
        public int width = 0;
        public int height = 0;
        public bool pausable = true;

        public double PosX
        {
            get
            {
                return this._position.X;
            }
            set
            {
                this._position = new Point(value, this._position.Y);
            }
        }
        public double PosY
        {
            get
            {
                return this._position.Y;
            }
            set
            {
                this._position = new Point(this._position.X, value);
            }
        }
        public double posRight
        {
            get
            {
                return this.PosX + this.width;
            }
            set
            {
                this.PosX = value - this.width;
            }
        }

        public double PosBottom
        {
            get
            {
                return this.PosY + this.height;
            }
            set
            {
                this.PosY = value - this.height;
            }
        }
        #endregion

        public EntityBase()
        {
        }

        public virtual void Update(GameTime time)
        {
        }

        public bool CollidesWith(EntityBase other)
        {
            if (
                this.posRight > other.PosX
                && this.PosX < other.posRight
                && this.PosBottom > other.PosY
                && this.PosY < other.PosBottom
                )
                return true;
            else
                return false;
            //if (
            //    this.posRight >= other.PosX
            //    && this.PosX <= other.posRight
            //    && this.PosBottom >= other.PosY
            //    && this.PosY <= other.PosBottom
            //    )
            //    return true;
            //else
            //    return false;
        }

        public bool CollidesWith(int x, int y)
        {
            if (this.PosX <= x && this.posRight > x
                && this.PosY <= y && this.PosBottom > y)
                return true;
            else
                return false;
        }
    }
}
